﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace SharpLib
{
    public class Circle
    {
        private Graphics gB;
        public Circle(Graphics g)
        {
            gB = g;
        }
        
        public void Point(int xc, int yc, int x, int y)
        {
            //Graphics gB = this.CreateGraphics();
            gB.DrawEllipse(Pens.Black, xc + x, yc + y, 1, 1);
            gB.DrawEllipse(Pens.Black, xc + x, yc - y, 1, 1);
            gB.DrawEllipse(Pens.Black, xc - x, yc + y, 1, 1);
            gB.DrawEllipse(Pens.Black, xc - x, yc - y, 1, 1);
            gB.DrawEllipse(Pens.Black, xc + y, yc + x, 1, 1);
            gB.DrawEllipse(Pens.Black, xc + y, yc - x, 1, 1);
            gB.DrawEllipse(Pens.Black, xc - y, yc + x, 1, 1);
            gB.DrawEllipse(Pens.Black, xc - y, yc - x, 1, 1);
        }

        public void DrawCircle(int xc, int yc, int r)
        {
            int d, x, y;
            x = 0;
            y = r;
            d = 3 - 2 * r;
            while (x <= y)
            {
                Point(xc, yc, x, y);
                if (d < 0)//chọn P
                {
                    d += 4 * x + 6;
                }
                else//chọn Q
                {
                    d += 4 * (x - y) + 10;
                    y--;
                }
                x++;
            }
        }
    }
}
